from visual import *

scene.title = "Bouncing Ball"
scene.background = (1,1,1)
scene.center = (0,8,25)
scene.autoscale = False 
floor = box (pos=(0,-3,0),length = 4 , height = 0.5, width = 4, color = color.blue)
ball = sphere (pos=(0,63,0), radius=2, color = color.red)
ball.velocity = vector(0,-2,0)
dt = 0.01
while 1:
    rate (100)
    ball.pos = ball.pos + ball.velocity * dt
    if ball.y < (floor.y+ball.radius):
        ball.velocity.y = -ball.velocity.y
    else:
        ball.velocity.y = ball.velocity.y -9.8*dt